local lijue = fk.CreateSkill {
  name = "lingling__lijuew",
}

Fk:loadTranslationTable{
  ["lingling__lijuew"] = "力绝",
  [":lingling__lijuew"] = "当你使用【杀】指定其他角色为目标后，你可以获得其一张牌或令其弃置两张牌，然后其可以失去1点体力对你执行另一项效果。",

  ["lingling__lijuew_prey"] = "获得%dest一张牌",
  ["lingling__lijuew_discard"] = "令%dest弃置两张牌",
  ["#lingling__lijuew-prey"] = "力绝：是否失去1点体力，获得 %src 一张牌？",
  ["#lingling__lijuew-discard"] = "力绝：是否失去1点体力，令 %src 弃置两张牌？",
}

lijue:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(lijue.name) and
      data.card.trueName == "slash" and data.to ~= player and not data.to:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local choice = room:askToChoice(player, {
      choices = { "lingling__lijuew_prey::"..data.to.id, "lingling__lijuew_discard::"..data.to.id, "Cancel" },
      skill_name = lijue.name,
    })
    if choice ~= "Cancel" then
      event:setCostData(self, { tos = { data.to }, choice = choice })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = event:getCostData(self).choice
    local prompt
    if choice:startsWith("lingling__lijuew_prey") then
      prompt = "#lingling__lijuew-discard:"..player.id
      local card = room:askToChooseCard(player, {
        target = data.to,
        flag = "he",
        skill_name = lijue.name,
      })
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, lijue.name, nil, false, player)
    else
      prompt = "#lingling__lijuew-prey:"..player.id
      room:askToDiscard(data.to, {
        min_num = 2,
        max_num = 2,
        include_equip = true,
        skill_name = lijue.name,
        cancelable = false,
      })
    end
    if player.dead or data.to.dead or data.to.hp < 1 then return end
    if room:askToSkillInvoke(data.to, {
      skill_name = lijue.name,
      prompt = prompt,
    }) then
      room:doIndicate(data.to, {player})
      room:loseHp(data.to, 1, lijue.name)
      if player.dead then return end
      if choice:startsWith("lingling__lijuew_prey") then
        room:askToDiscard(player, {
          min_num = 2,
          max_num = 2,
          include_equip = true,
          skill_name = lijue.name,
          cancelable = false,
        })
      elseif not data.to.dead and not player:isNude() then
        local card = room:askToChooseCard(data.to, {
          target = player,
          flag = "he",
          skill_name = lijue.name,
        })
        room:moveCardTo(card, Card.PlayerHand, data.to, fk.ReasonPrey, lijue.name, nil, false, data.to)
      end
    end
  end,
})

return lijue
